# eric7.WebBrowser.OpenSearch.OpenSearchManager

Module implementing a manager for open search engines.

### Global Attributes

None

### Classes

OpenSearchManager | Class implementing a manager for open search engines.

### Functions

None

## OpenSearchManager

Class implementing a manager for open search engines.

### Signals

changed()
  emitted to indicate a change
currentEngineChanged()
  emitted to indicate a change of the current search engine

### Derived from

QObject

### Class Attributes

None

### Class Methods

None

### Methods

OpenSearchManager | Constructor
__addEngineByEngine | Private method to add a new search engine given a reference to an engine.
__addEngineByFile | Private method to add a new search engine given a filename.
__addEngineByUrl | Private method to add a new search engine given its URL.
__confirmAddition | Private method to confirm the addition of a new search engine.
__engineFromUrlAvailable | Private slot to add a search engine from the net.
addEngine | Public method to add a new search engine.
addEngineFromForm | Public method to add a new search engine from a form.
allEnginesNames | Public method to get a list of all engine names.
close | Public method to close the open search engines manager.
convertKeywordSearchToUrl | Public method to get the search URL for a keyword search.
currentEngine | Public method to get a reference to the current engine.
currentEngineName | Public method to get the name of the current search engine.
engine | Public method to get a reference to the named engine.
engineExists | Public method to check, if an engine exists.
engineForKeyword | Public method to get the engine for a keyword.
enginesChanged | Public slot to tell the search engine manager, that something has changed.
enginesCount | Public method to get the number of available engines.
enginesDirectory | Public method to determine the directory containing the search engine descriptions.
generateEngineFileName | Public method to generate a valid engine file name.
keywordsForEngine | Public method to get the keywords for a given engine.
load | Public method to load the search engines configuration.
loadDirectory | Public method to load the search engine definitions from files.
removeEngine | Public method to remove an engine.
restoreDefaults | Public method to restore the default search engines.
save | Public method to save the search engines configuration.
saveDirectory | Public method to save the search engine definitions to files.
setCurrentEngine | Public method to set the current engine.
setCurrentEngineName | Public method to set the current engine by name.
setEngineForKeyword | Public method to set the engine for a keyword.
setKeywordsForEngine | Public method to set the keywords for an engine.

### Static Methods

None

#### OpenSearchManager (Constructor)

OpenSearchManager(parent=None)

Constructor

parent (QObject)
  reference to the parent object

#### OpenSearchManager.__addEngineByEngine

__addEngineByEngine(engine)

Private method to add a new search engine given a reference to an engine.

engine (OpenSearchEngine)
  reference to an engine object

Return:
  flag indicating success

Return Type:
  bool

#### OpenSearchManager.__addEngineByFile

__addEngineByFile(filename)

Private method to add a new search engine given a filename.

filename (str)
  name of a file containing the engine definition

Return:
  flag indicating success

Return Type:
  bool

#### OpenSearchManager.__addEngineByUrl

__addEngineByUrl(url)

Private method to add a new search engine given its URL.

url (QUrl)
  URL of the engine definition file

Return:
  flag indicating success

Return Type:
  bool

#### OpenSearchManager.__confirmAddition

__confirmAddition(engine)

Private method to confirm the addition of a new search engine.

engine (OpenSearchEngine)
  reference to the engine to be added

Return:
  flag indicating the engine shall be added

Return Type:
  bool

#### OpenSearchManager.__engineFromUrlAvailable

__engineFromUrlAvailable(reply)

Private slot to add a search engine from the net.

reply (QNetworkReply)
  reference to the network reply

#### OpenSearchManager.addEngine

addEngine(engine)

Public method to add a new search engine.

engine (str)
  URL of the engine definition file (QUrl) or name of a file containing the engine definition or reference to an engine object (OpenSearchEngine)

Return:
  flag indicating success

Return Type:
  bool

#### OpenSearchManager.addEngineFromForm

addEngineFromForm(res, view)

Public method to add a new search engine from a form.

res (dict or None)
  result of the JavaScript run on by WebBrowserView.__addSearchEngine()
view (WebBrowserView)
  reference to the web browser view

#### OpenSearchManager.allEnginesNames

allEnginesNames()

Public method to get a list of all engine names.

Return:
  sorted list of all engine names

Return Type:
  list of str

#### OpenSearchManager.close

close()

Public method to close the open search engines manager.

#### OpenSearchManager.convertKeywordSearchToUrl

convertKeywordSearchToUrl(keywordSearch)

Public method to get the search URL for a keyword search.

keywordSearch (str)
  search string for keyword search

Return:
  search URL

Return Type:
  QUrl

#### OpenSearchManager.currentEngine

currentEngine()

Public method to get a reference to the current engine.

Return:
  reference to the current engine

Return Type:
  OpenSearchEngine

#### OpenSearchManager.currentEngineName

currentEngineName()

Public method to get the name of the current search engine.

Return:
  name of the current search engine

Return Type:
  str

#### OpenSearchManager.engine

engine(name)

Public method to get a reference to the named engine.

name (str)
  name of the engine

Return:
  reference to the engine

Return Type:
  OpenSearchEngine

#### OpenSearchManager.engineExists

engineExists(name)

Public method to check, if an engine exists.

name (str)
  name of the engine

Return:
  flag indicating an existing engine

Return Type:
  bool

#### OpenSearchManager.engineForKeyword

engineForKeyword(keyword)

Public method to get the engine for a keyword.

keyword (str)
  keyword to get engine for

Return:
  reference to the search engine object

Return Type:
  OpenSearchEngine

#### OpenSearchManager.enginesChanged

enginesChanged()

Public slot to tell the search engine manager, that something has changed.

#### OpenSearchManager.enginesCount

enginesCount()

Public method to get the number of available engines.

Return:
  number of engines

Return Type:
  int

#### OpenSearchManager.enginesDirectory

enginesDirectory()

Public method to determine the directory containing the search engine descriptions.

Return:
  directory name

Return Type:
  str

#### OpenSearchManager.generateEngineFileName

generateEngineFileName(engineName)

Public method to generate a valid engine file name.

engineName (str)
  name of the engine

Return:
  valid engine file name

Return Type:
  str

#### OpenSearchManager.keywordsForEngine

keywordsForEngine(engine)

Public method to get the keywords for a given engine.

engine (OpenSearchEngine)
  reference to the search engine object

Return:
  list of keywords

Return Type:
  list of str

#### OpenSearchManager.load

load()

Public method to load the search engines configuration.

#### OpenSearchManager.loadDirectory

loadDirectory(dirName)

Public method to load the search engine definitions from files.

dirName (str)
  name of the directory to load the files from

Return:
  flag indicating success

Return Type:
  bool

#### OpenSearchManager.removeEngine

removeEngine(name)

Public method to remove an engine.

name (str)
  name of the engine

#### OpenSearchManager.restoreDefaults

restoreDefaults()

Public method to restore the default search engines.

#### OpenSearchManager.save

save()

Public method to save the search engines configuration.

#### OpenSearchManager.saveDirectory

saveDirectory(dirName)

Public method to save the search engine definitions to files.

dirName (str)
  name of the directory to write the files to

#### OpenSearchManager.setCurrentEngine

setCurrentEngine(engine)

Public method to set the current engine.

engine (OpenSearchEngine)
  reference to the new current engine

#### OpenSearchManager.setCurrentEngineName

setCurrentEngineName(name)

Public method to set the current engine by name.

name (str)
  name of the new current engine

#### OpenSearchManager.setEngineForKeyword

setEngineForKeyword(keyword, engine)

Public method to set the engine for a keyword.

keyword (str)
  keyword to get engine for
engine (OpenSearchEngine)
  reference to the search engine object or None to remove the keyword

#### OpenSearchManager.setKeywordsForEngine

setKeywordsForEngine(engine, keywords)

Public method to set the keywords for an engine.

engine (OpenSearchEngine)
  reference to the search engine object
keywords (list of str)
  list of keywords

Up